﻿define(function (require, exports, module) {
    require('plugins/datetime/daterangepicker.css');
    require('plugins/datetime/daterangepicker')($);
    //公有属性和方法
    var dateRange = null;
    module.exports = {
        init: function (jq, params) {
            dateRange = jq.daterangepicker({
                "showDropdowns": true,
                "timePicker24Hour": true,
                "startDate": moment(),
                "endDate": moment().add(29, 'days'),
                "ranges": {
                    "30天": [moment(), moment().add(29, 'days')],
                    "60天": [moment(), moment().add(59, 'days')],
                    "3个月": [moment(), moment().add(3, 'months')],
                    "6个月": [moment(), moment().add(6, 'months')],
                    "1年": [moment(), moment().add(1, 'years')],
                    "2年": [moment(), moment().add(2, 'years')],
                    "3年": [moment(), moment().add(3, 'years')]
                },
                "locale": {
                    "direction": "ltr",
                    "separator": " - ",
                    "applyLabel": "确定",
                    "cancelLabel": "取消",
                    "fromLabel": "From",
                    "toLabel": "To",
                    "customRangeLabel": "自选",
                    "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
                    "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
                    "firstDay": 1,
                    "format": params.format
                },
                "alwaysShowCalendars": true,
                drops: "up"

            }, function (start, end, label) {
                params.onSelect(start, end, label);
            }); 
        },
        setValue: function (start, end) {
            dateRange.data('daterangepicker').setStartDate(start);
            dateRange.data('daterangepicker').setEndDate(end);

        }
    }
});

 